﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Material.Domain;
using T_Material.Infrastructure.Interface;
using T_Material.Read.API.Application.Commands.WarehousingCommand;

namespace T_Material.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WarehousingRApiController : ControllerBase
    {
        private readonly IMediator mediator;

        public WarehousingRApiController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 线路列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Warehousing>> GetLineList([FromQuery] WarehousingListCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 根据线路Id找到线路实体
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Warehousing> GetLineInfo([FromQuery] WarehousingInfoCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
